Skip to content

[monitoring-template] feat(mysql): add database account expiry metrics#3969

Merged
zqr10159 merged 8 commits into
apache:masterfrom
BhanuNidumolu:feature/mysql-account-expiry
Jan 18, 2026
Merged

[monitoring-template] feat(mysql): add database account expiry metrics#3969
zqr10159 merged 8 commits into
apache:masterfrom
BhanuNidumolu:feature/mysql-account-expiry

Conversation

@BhanuNidumolu

Copy link
Copy Markdown
Contributor

What's changed?

This PR adds database account expiry monitoring for MySQL as part of issue #2757.

A new account_expiry metric is introduced in app-mysql.yml that exposes:

  • user
  • host
  • password_lifetime
  • password_last_changed
  • password_expired
  • days_left (remaining days before expiry)

This enables HertzBeat users to alert on:

  • expired accounts
  • accounts expiring in N days
  • security & credential risks

Verification

I validated this using real MySQL users:

SELECT
  user,
  host,
  password_lifetime,
  password_last_changed,
  password_expired,
  IF(password_lifetime IS NULL,
     NULL,
     password_lifetime - DATEDIFF(NOW(), password_last_changed)
  ) AS days_left
FROM mysql.user;

Test users:

test_expire_5 → 4 days remaining
test_expired → expired

HertzBeat UI shows the same values for Days Left and Expired flag.

Screenshots attached:
image
image

Checklist

  • I have read the Contributing Guide
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Add or update API

  • I have added the necessary e2e tests and all cases have passed.

@BhanuNidumolu

Copy link
Copy Markdown
Contributor Author

Manual validation was performed with real MySQL users.

The SQL result from mysql.user and the HertzBeat Account Expiry panel show identical:

  • user
  • host
  • days_left
  • password_expired

This confirms the template, collector and UI pipeline are working correctly.

Comment thread home/docs/help/mysql_account_expiry.md Outdated
Comment on lines +1 to +13
# MySQL Account Expiry

HertzBeat supports monitoring of MySQL database account password expiration,
allowing administrators to detect expired or soon-to-expire accounts and
configure alerts.

---

## Metric: account_expiry

This metric collects password expiration information for all MySQL users.

### Fields

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi the document md can not put in the define yml dir. The website doc is a good place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I’ve moved the MySQL account expiry documentation into the website help docs as suggested.

@github-actions github-actions Bot added the doc Improvements or additions to documentation label Jan 15, 2026
@zqr10159

Copy link
Copy Markdown
Member

Please fix markdown error.

@BhanuNidumolu

Copy link
Copy Markdown
Contributor Author

Thanks for pointing it out!

I’ve fixed the markdown issue by updating the MySQL account expiry documentation:

  • Resolved markdownlint errors
  • Moved the content into a standalone help doc
  • Ensured the front-matter and formatting pass all checks

Please let me know if anything else needs adjustment.

@zqr10159 zqr10159 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zqr10159 zqr10159 merged commit 4b010e6 into apache:master Jan 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend doc Improvements or additions to documentation monitoring-template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants